<?

	$query = "

		SELECT		*
		FROM		`content`
		WHERE		`delete` IS NULL
		AND			`key` = '" . $_REQUEST[ "JO_content" ] . "'

	";

	$recordSet = JO_query( $query );

	if( $recordSet -> num_rows )	$record = $recordSet -> fetch_array( );
	else							JO_location( "." );

?>



<? if( $record[ "image" ] ) { ?>

	<div class="JO_unit">

		<h1><?

			switch( $record[ "unit" ] ) {

				case "neowiz":	echo "Neowiz Internet Vietnam";		break;
				default:		echo ucwords( $record[ "unit" ] );	break;

			}

		?></h1>

            <div class="unit"><img src="<?= $record[ "image" ] ?>" /></div>

	</div>

<? } else { ?>

	<div class="JO_page">

		<h1><?

			switch( $record[ "unit" ] ) {

				case "neowiz":	echo "Neowiz Internet Vietnam";		break;
				default:		echo ucwords( $record[ "unit" ] );	break;

			}

		?></h1>

		<h2>&nbsp;</h2>

	</div>

<? } ?>




<div class="JO_relative" style="width: 960px;">



	<?

		if( $record[ "unit" ] ) {

		////
		///
		//	Page

			$JO_content_limit = 20;

			$query = "

				SELECT		COUNT( `key` ) AS `count`
				FROM		`content`
				WHERE		`delete` IS NULL
				AND			`unit` = '" . $record[ "unit" ] . "'

			";

			$recordSet = JO_query( $query );

			$recordCount = $recordSet -> fetch_array( );



		////
		///
		//	List

			if( ! $_REQUEST[ "JO_page" ] ) $_REQUEST[ "JO_page" ] = "1";

			$query = "

				SELECT		*
				FROM		`content`
				WHERE		`delete` IS NULL
				AND			`unit` = '" . $record[ "unit" ] . "'
				ORDER BY	`insert` DESC,
							`key` ASC
				LIMIT		" . ( ( intval( $_REQUEST[ "JO_page" ] ) - 1 ) * $JO_content_limit ) . ", " . $JO_content_limit . "

			";

			$recordSet = JO_query( $query );

	?>

		<div class="JO_box_240 JO_left">

			<h1><?= ucwords( $record[ "unit" ] ) ?><?= $record[ "unit" ] == "neowiz" ? " Internet Vietnam" : "" ?></h1>



			<!-- Page -->

				<? if( $record[ "unit" ] != "neowiz" && $record[ "unit" ] != "jay" ) { ?>

					<h2>

						<? if( intval( $_REQUEST[ "JO_page" ] ) > 2 ) { ?>

							&nbsp; <a href="?JO_content=<?= $_REQUEST[ "JO_content" ] ?>&JO_page=<?= intval( $_REQUEST[ "JO_page" ] ) - 2 ?>">...</a>

						<? } ?>

						<? if( intval( $_REQUEST[ "JO_page" ] ) > 1 ) { ?>

							&nbsp; <a href="?JO_content=<?= $_REQUEST[ "JO_content" ] ?>&JO_page=<?= intval( $_REQUEST[ "JO_page" ] ) - 1 ?>"><?= intval( $_REQUEST[ "JO_page" ] ) - 1 ?></a>

						<? } ?>

						&nbsp; <a href="" class="JO_black"	><?= intval( $_REQUEST[ "JO_page" ] )		?></a>

						<? if( intval( $_REQUEST[ "JO_page" ] ) < floor( ( intval( $recordCount[ "count" ] ) - 1 ) / $JO_content_limit ) + 1 ) { ?>

							&nbsp; <a href="?JO_content=<?= $_REQUEST[ "JO_content" ] ?>&JO_page=<?= intval( $_REQUEST[ "JO_page" ] ) + 1 ?>"><?= intval( $_REQUEST[ "JO_page" ] ) + 1	?></a>

						<? } ?>

						<? if( intval( $_REQUEST[ "JO_page" ] ) < floor( ( intval( $recordCount[ "count" ] ) - 1 ) / $JO_content_limit ) ) { ?>

							&nbsp; <a href="?JO_content=<?= $_REQUEST[ "JO_content" ] ?>&"JO_page=<?= intval( $_REQUEST[ "JO_page" ] ) + 2 ?>>...</a>

						<? } ?>

					</h2>

				<? } ?>



			<!-- List -->

				<? if( $record[ "unit" ] != "neowiz" && $record[ "unit" ] != "jay" ) { ?>

					<? while( $recordList = $recordSet -> fetch_array( ) ) { ?>

						<a href="?JO_content=<?= $recordList[ "key" ] ?>" class="JO_menu" style="position: relative;">

							<div style="position: absolute; left: 2px; top: 2px; width: 60px;"><?= JO_date( $recordList[ "insert" ] ) ?></div>

							<div style="padding: 2px 0px 2px 63px; width: 155px;"><?= $recordList[ "subject" ] ?></div>

						</a>

					<? } ?>

				<? } else { ?>

					<? while( $recordList = $recordSet -> fetch_array( ) ) { ?>

						<a href="?JO_content=<?= $recordList[ "key" ] ?>" class="JO_menu"><?= JO( $recordList[ "subject" ] ) ?></a>

					<? } ?>


				<? } ?>	



		</div>

	<? } else { ?>

		<div class="JO_left" style="width: 240px;">&nbsp;</div>

	<? } ?>



	<div class="JO_bar_720 JO_left">

		<h1><?= JO( $record[ "subject" ] ) ?></h1>

		<? if( $record[ "unit" ] != "neowiz" && $record[ "unit" ] != "jay" ) { ?>

			<h2><?= substr( $record[ "insert" ], 0,	4 ) != "0000" ? JO_date( $record[ "insert" ] ) : "" ?></h2>

		<? } ?>

		<div><?= JO( $record[ "content" ] ) ?></div>

	</div>

</div>
